{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2022-01-07 13:39:58.136195\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "# 当前日期\n",
    "print(datetime.now())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2020-03-01 00:00:00\n"
     ]
    }
   ],
   "source": [
    "# 按照格式要求输入日期时间\n",
    "year, month, day = eval(input(\"输入year\")), eval(input(\"输入month\")), eval(input(\"输入day\"))\n",
    "date = datetime(year, month, day)\n",
    "print(date)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'datetime.timedelta'>\n",
      "694876709.3604391\n"
     ]
    }
   ],
   "source": [
    "date1 = datetime(2000, 1, 1)\n",
    "date2 = datetime.now()\n",
    "\n",
    "print(date2 - date1)\n",
    "# 相差秒数\n",
    "print(date2.timestamp() - date1.timestamp())"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "c5eaa1b04e3c36593f041bc63175cf09461113a05410d10cdac056a8b8023424"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 64-bit ('base': conda)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
